package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.ComplaintStatusRepository;
import org.example.petitionplatformsystem.dao.model.ComplaintStatus;
import org.example.petitionplatformsystem.service.ComplaintStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComplaintStatusServiceImpl implements ComplaintStatusService {
    @Autowired
    private ComplaintStatusRepository complaintStatusRepository;

    @Override
    public void addComplaintStatus(ComplaintStatus complaintStatus) {
        complaintStatusRepository.save(complaintStatus);
    }

    @Override
    public void updateComplaintStatus(ComplaintStatus complaintStatus) {
        complaintStatusRepository.save(complaintStatus);
    }

    @Override
    public void deleteComplaintStatus(ComplaintStatus complaintStatus) {
        complaintStatusRepository.delete(complaintStatus);
    }

    @Override
    public ComplaintStatus getComplaintStatusById(long id) {
        return complaintStatusRepository.findById(id).orElse(null);
    }

    @Override
    public List<ComplaintStatus> getAllComplaintStatuses() {
        return complaintStatusRepository.findAll();
    }

    @Override
    public List<Integer> getPetitionAllStatus(long eventId) {
        return complaintStatusRepository.findReplyContentByEventIDOrderByUpdateTimeDesc(eventId);
    }

    @Override
    public List<String> getPetitionAllStatusData(long eventId) {
        return complaintStatusRepository.findUpdateTimeByEventIDOrderByUpdateTimeDesc(eventId);
    }
}
